<template>
  <common-search :col-layout="{xxl: 6, xl:8, lg: 8, md: 12, sm: 24, xs: 24}" v-model="query" :formItems="formItems" @search="search" @reset="reset"></common-search>
  <common-table
      :columns="columns"
      :dataSource="dataList"
      v-model:localPagination="page"
      @paginationChange="onPageChange"
      v-model:loading="loading"
      :scroll="{ x: 'max-content'}"
  >
  </common-table>
</template>
<script>
export default {
  name:'tail-truckData'
}
</script>
<script setup>
import { ref,onMounted } from "vue";
import CommonTable from "@/components/commonTable/index.vue";
import CommonSearch from "@/components/commonSearch/index.vue";
import {useSearchTable} from "@/hooks/table/useSearchTable";
import {getManyDictItems} from "@/api/system/dict.js";
import {message} from "ant-design-vue";
import {postFile} from "@utils/service/index.js";
import {getTruckFreightRate} from "@/api/tail/truckData.js";
const columns = [
  {
    "dictCode": "site",
    "dataIndex": "site",
    "title": "站点",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dataIndex": "poolCode",
    "title": "库存池",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dataIndex": "warehouseCode",
    "title": "仓库",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dataIndex": "etaDate",
    "title": "到港ETA",
    "align": "center",
    "fieldType": "Date"
  },
  {

    "dataIndex": "productSku",
    "title": "平台SKU",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dataIndex": "versionCode",
    "title": "版本",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dataIndex": "warehouseSku",
    "title": "仓库SKU",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dataIndex": "qty",
    "title": "库存数量",
    "align": "center",
    "fieldType": "Long"
  },
  {

    "dataIndex": "orderQty",
    "title": "待处理",
    "align": "center",
    "fieldType": "Long"
  },
  {

    "dataIndex": "pkgSize",
    "title": "分包数",
    "align": "center",
    "fieldType": "Long"
  },
  {

    "dictCode": "pdmProductType",
    "dataIndex": "productType",
    "title": "产品类型",
    "align": "center",
    "fieldType": "String"
  },
  {

    "dictCode": "deliveryType",
    "dataIndex": "deliveryType",
    "title": "物流类型",
    "align": "center",
    "fieldType": "String"
  }
]
const formItems = ref([])
const selectedRowKeys = ref([])
const exportLoading = ref(false)
const { dataList, query, loading, page, search, reset, onPageChange } = useSearchTable({
  searchAPI: getTruckFreightRate,
  queryFactory: () => ({
  }),
  beforeSearch: () => {
  },
});
/**
 * 初始化字典数据
 * @returns {Promise<void>}
 */
const init = async () => {
  try{
    const res = await getManyDictItems({
      dictCodeList:"site,delivery_type,sku_type"
    })
    formItems.value[0].options = res.result.site
    formItems.value[4].options = res.result.delivery_type
    formItems.value[5].options = res.result.sku_type
  }catch (e){
    console.log(e)
  }
}
/**
 *  选择行变化事件
 * @param e {Array} 选择行的keys
 */
const onSelectChange = (e) => {
  selectedRowKeys.value = e
}
const exports = async () => {
  try{
    exportLoading.value = true
    const res = await postFile('/inventoryPool/part/export','post',query.value,'配件散件库存池.xlsx')
    message.success('导出成功')
  }catch (e) {
    message.error(e)
  }finally {
    exportLoading.value = false
  }
}
onMounted(()=>{
  init()
})
</script>
<style scoped>

</style>
